package com.csp.app.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.csp.app.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select max(id) from user")
    Long selectMaxAccount();

    @Select("SELECT u.id,u.username,u.avatar,u.sign FROM `user` u WHERE id in (SELECT friend_id FROM friend WHERE id=#{id})")
    List<User> selectAddedFriendById(@Param("id") Long id);

    @Insert("insert `user`(id,username,password,sex,sign,age,birthday) " +
            "values(#{id},#{username},#{password},#{sex},#{sign},#{age},#{birthday}) ")
    Integer addUser(User user);
}
